# 这是一个示例 Python 脚本。

# 按 Shift+F10 执行或将其替换为您的代码。
# 按 双击 Shift 在所有地方搜索类、文件、工具窗口、操作和设置。

a = 'ABCrtyrwwq%%&&*uC'

t = [{'小': {}}, {'大': {}}, {'特': {}}]

for i in a:
    if 65 <= ord(i) <= 90:
        try:
            a = t[1]["大"][i]
        except Exception as e:
            t[1]["大"][i] = 1
            continue
        t[1]["大"][i] = t[1]["大"][i] + 1
    elif 97 <= ord(i) <= 122:
        try:
            a = t[0]["小"][i]
        except Exception as e:
            t[0]["小"][i] = 1
            continue
        t[0]["小"][i] = t[0]["小"][i] + 1
    else:
        try:
            a = t[2]["特"][i]
        except Exception as e:

            t[2]["特"][i] = 1
            continue
        t[2]["特"][i] = t[2]["特"][i] + 1

print("第一题")
print(t)

d = {
    "a": "d",
    "b": "d",
    "c": "d",
    "e": "d",
    "r": "p",
}
# {"d":"a","p":"r"}
# {"d":"e","p":"r"}
# {"d":["b","c"]}
print("第二题")
dict1 = {}
for i, k in d.items():
    try:
        n = dict1[k]
    except Exception as e:
        dict1[k] = i
print(dict1, 'dict1')
dict2 = {}
for i, k in d.items():
    dict2[k] = i
print(dict2, 'dict2')
dict3 = {}
dict4 = {}
for i, k in d.items():
    try:
        n = dict1[k]
        if i == n:
            continue
    except Exception as e:
        pass
    try:
        n = dict2[k]
        if i == n:
            continue
    except Exception as e:
        pass
    dict4[i] = k
for i, k in dict4.items():
    list_ = []
    for j, l in dict4.items():
        if k == l:
            list_.append(j)
    dict3[k] = list_
print(dict3, "dict3")

print("第三题")
lis = [[2, 6, ], [3, 3, ], [7, 2, ], [8, 9, ], [14, 1, ]]
for i in range(0, len(lis)):
    if lis[i][0] % 7 == 0:
        lis[i].append("过")
        continue
    lis[i].append(str(lis[i][0]))

print(lis)


def xz(list_):

    for i in range(1, len(list_)):
        # 当前需要插入的元素
        n = list_[i]
        # 与当前元素比较的比较元素
        pre_index = i - 1
        while pre_index >= 0 and list_[pre_index][1] > n[1]:
            # 当比较元素大于当前元素则把比较元素后移
            list_[pre_index + 1] = list_[pre_index]
            # 前往选择下一个比较元素
            pre_index -= 1
        # 当比较元素小于当前元素,则将当前元素插入在其后面
        list_[pre_index + 1] = n
    return list_


a = xz(lis)


print(a)
